#include <iostream>
#include <cstring>

using namespace std;

char c[100][100];
int ntest = 0, n, m;

char cal(int x, int y)
{
	int res = 0;
	for (int i = -1; i <= 1; i++)
		for (int j = -1; j <= 1; j++)
		{
			if (i == 0 && j == 0) continue;
			int xx = x + i, yy = y + j;
			if (xx < 0 || xx >= n || yy < 0 || yy >= m) continue;
			if (c[xx][yy] == '*') res++;
		}
	return res + '0';
}

int main()
{
	while (true)
	{
		scanf("%d %d\n", &n, &m);
		if (n == 0 && m == 0) break;
		memset(c, 0, sizeof(c));
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)	cin >> c[i][j];
			scanf("\n");
		}

		if (ntest > 0) cout << endl; // be careful about this as it causes WA with an extra empty line
		ntest++;
		cout << "Field #" << ntest << ":" << endl;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (c[i][j] != '*') c[i][j] = cal(i, j);
				cout << c[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}
